#ifndef __COMMON_FUNCTIONS_HPP
#define __COMMON_FUNCTIONS_HPP

#if DEBUG
	#define null_if_fail(cond) if (!cond) { \
		php_printf("%s failed at %s:%d", #cond, __FILE__, __LINE__); \
		RETURN_NULL(); \
	}
#else
	#define null_if_fail(cond) if (!cond) { RETURN_NULL(); }
#endif

#define const_str_length_ptr(str) (char *)str, sizeof(str) - 1
#define const_length_str_ptr(str) sizeof(str) - 1, (char *)str
#define const_str_length(str) str, sizeof(str) - 1
#define const_length_str(str) sizeof(str) - 1, str
#define const_obj_size(str)   str, sizeof(str)
#define const_size_obj(str)   sizeof(str), str

static inline bool call_method(zval *obj, const char *name, uint length, zval **ret, uint param_count, ...); 
static inline bool call_function(const char *name, zval **obj_pp, zval *ret, uint count_args, zval **args); 
static inline bool call_function(const char *name, zval **obj_pp, zval *ret, uint count_args, ...); 
static inline zval *get_class_by_name(const char *name, uint length); 
ZEND_API int zend_call_method_extended(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval ***params TSRMLS_DC); 

#endif // __COMMON_FUNCTIONS_HPP
